//
//  UCMutablePath.m
//  AeroMapSDK
//
//  Created by 北京国泰北斗科技有限公司 on 2017/3/10.
//  Copyright © 2017年 北京国泰北斗科技有限公司. All rights reserved.
//

#import "UCMutablePath.h"
#import <GoogleMaps/GoogleMaps.h>
#import "UCGeometryUtils.h"

@interface UCMutablePath ()

@property(nonatomic,strong)GMSMutablePath *gmPath;
@property(nonatomic,strong)NSMutableArray *markers;
@end

@implementation UCMutablePath

+ (instancetype)path{
    
    UCMutablePath *myPath = [[UCMutablePath alloc] init];
    myPath.gmPath = [GMSMutablePath path];
    myPath.markers = [[NSMutableArray alloc] init];
    return myPath;
}

- (id)initWithPath:(UCPath *)path{
    
    UCMutablePath *myPath = [[UCMutablePath alloc] init];
    myPath.gmPath = [[GMSMutablePath alloc] initWithPath:[path valueForKey:@"gmPath"]];
    myPath.markers = [[NSMutableArray alloc] init];
    return myPath;
}

- (instancetype)init{
    self = [super init];
    if (self) {
        self.gmPath = [[GMSMutablePath alloc] init];
        self.markers = [[NSMutableArray alloc] init];
    }
    return self;
}

- (void)addCoordinate:(CLLocationCoordinate2D)coord{
    
    [self.gmPath addCoordinate:coord];
}

- (void)addLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude{

    [self.gmPath addLatitude:latitude longitude:longitude];
}

- (void)insertCoordinate:(CLLocationCoordinate2D)coord atIndex:(NSUInteger)index{
    [self.gmPath insertCoordinate:coord atIndex:index];
}

- (void)replaceCoordinateAtIndex:(NSUInteger)index
                  withCoordinate:(CLLocationCoordinate2D)coord{
    [self.gmPath replaceCoordinateAtIndex:index withCoordinate:coord];
    
    
}

- (void)removeCoordinateAtIndex:(NSUInteger)index{

    [self.gmPath removeCoordinateAtIndex:index];
}

- (void)removeLastCoordinate{

    [self.gmPath removeLastCoordinate];
}

- (void)removeAllCoordinates{

    [self.gmPath removeAllCoordinates];
}

@end
